package com.csc.finalproject.controller;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.TypedQuery;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.csc.finalproject.dao.AccountInfoDAO;
import com.csc.finalproject.dao.AccountInfoDAOImpl;
import com.csc.finalproject.dao.RoleDAO;
import com.csc.finalproject.dao.StateDAO;
import com.csc.finalproject.dao.UserDAO;
import com.csc.finalproject.dao.UserDAOImpl;
import com.csc.finalproject.domain.AccountInfo;
//import com.csc.finalproject.dao.UserDAOImpl;
import com.csc.finalproject.domain.DepositeAccount;
import com.csc.finalproject.domain.Role;
import com.csc.finalproject.domain.State;
import com.csc.finalproject.domain.User;
import com.csc.finalproject.service.AccountInfoService;
//import com.csc.finalproject.service.UserService;
import com.csc.finalproject.service.UserService;

@Controller
public class HelloWorldContrller {
	@Autowired
	UserService userService;
	//@Autowired
	//AccountInfoService accService;

	// @Autowired UserDAOImpl userDAO;
	// @Autowired AccountInfoDAOImpl accDAO;
	// @Autowired RoleDAO roleDAO;
	// @Autowired StateDAO stateDAO;
	@RequestMapping(value = "/hello", method = RequestMethod.GET)
	public String hello() {

		// UserDAO userDAO = new UserDAO();
		// System.out.println(userDAO.getUsers().size());
		/*
		 * AccountInfoDAO accDAO = new AccountInfoDAO(); List<AccountInfo>
		 * accountInfos = accDAO.getAccounts();
		 * System.out.println(accountInfos.size()); for (AccountInfo accountInfo
		 * : accountInfos) { List<DepositeAccount> depositeAccounts =
		 * accountInfo.getDepositeAccount(); for (DepositeAccount
		 * depositeAccount : depositeAccounts) {
		 * System.out.println(depositeAccount.getName()); }
		 * System.out.println(accountInfo.getAccountId() ); }
		 * 
		 * 
		 * AccountInfo account = accDAO.getAccount(1);
		 * System.out.println(account.getLastName());
		 */

		// accDAO.add(5, "1331","1333111", "N33ew", "Name", "Mid", "11", "12",
		// "md", "df", 1);

		// accDAO.addAccount(5, "1331","1333111", "N33ew", "Name", "Mid", "11",
		// "12", "md", "df", 1);

		/*
		 * RoleDAO roleDAO= new RoleDAO(); List<Role> roles=roleDAO.getRoles();
		 * System.out.println(roles.size()); for(Role role: roles){
		 * System.out.println(role.getRoleId()); }
		 * 
		 * //accDAO.editAccount(8, "3", "2", "3", "3", "3", "3", "3", "3", "3",
		 * 3);
		 * 
		 * 
		 * Role addRole=roleDAO.getRole(1); roleDAO.addRole(2, "Active");
		 */

		/*
		 * List<State> states=stateDAO.getStates(); for(State state:states){
		 * System.out.println(state.getStateId()); } State
		 * addState=stateDAO.getState(1); stateDAO.addState("disactive3");
		 */
		// accDAO.addAccount(newAccount);
		/*
		 * StateDAO stateDAO = new StateDAO(); stateDAO.getStates();
		 */
		/*
		 * UserDAO userDAO = new UserDAO(); userDAO.getUsers();
		 */

		// userService.getUser();
		// userDAO.getUsers();

		// User2 user = new User2();
		// user.setPassword("1232");
		// user.setUserId(1);
		// user.setUsername("Phu2c");

		// UserDAO accDAO = new UserDAOImpl();
		// int size = accDAO.getAll().size();
		// System.out.println(size);

		userService.addUser("newddd", "psw");
		List<User> lAccount = userService.getUsers();
		System.out.println(lAccount.size());
		return "login";
	}

}
